using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Deepcode.Flux.Core.Data;

namespace Deepcode.Flux.Core.Systems.Audit
{
	/// <summary>
	/// Class describing a single system event record
	/// </summary>
	public class SystemEvent
	{
		private int				_PK_ID = -1;
		private DateTime		_DateTimeStamp = System.DateTime.Now;
		private int				_FK_User = -1;
		private EventSeverity	_Severity = EventSeverity.Trace;
		private EventType		_Type = EventType.System;
		private string			_Class = "";
		private string			_App = "";
		private string			_Message = "";

		public int				PK_ID{ get{ return _PK_ID; } set{ _PK_ID = value; }}
		public DateTime			DateTimeStamp{ get{ return _DateTimeStamp; } set{ _DateTimeStamp = value; }}
		public int				FK_User{ get{ return _FK_User; } set{ _FK_User = value; }}
		public EventSeverity	Severity{ get{ return _Severity; } set{	_Severity = value; }}
		public EventType		Type{ get{ return _Type; } set{ _Type = value; }}
		public string			Class{ get{ return _Class; } set{ _Class = value; }}
		public string			App{ get{ return _App; } set{ _App = value; }}
		public string			Message{ get{ return _Message; }set{ _Message=value; }}

		public SystemEvent()
		{
		}

		public SystemEvent( DataRow r )
		{
			PK_ID			= SQLUtility.DBNull(r["PK_ID"], -1);
			DateTimeStamp	= SQLUtility.DBNull(r["DateTimeStamp"], System.DateTime.Now);
			FK_User			= SQLUtility.DBNull(r["FK_User"], -1);
			Severity		= (EventSeverity) SQLUtility.DBNull(r["Severity"], (int) EventSeverity.Trace);
			Type			= (EventType) SQLUtility.DBNull(r["Type"], (int) EventType.System);
			Class			= SQLUtility.DBNull(r["Class"], "");
			App				= SQLUtility.DBNull(r["App"], "");
			Message			= SQLUtility.DBNull(r["Message"], "");
		}
	}
}
